import random
import string

def generate_random_str(length: int) -> str:
    """生成包含大小写字母和数字的随机字符串"""
    # 定义字符集：大小写字母 + 数字
    characters = string.ascii_letters + string.digits  # 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
    # 从字符集中随机选择length个字符，拼接成字符串
    return ''.join(random.choice(characters) for _ in range(length))

# 示例：生成10位随机字符串
print(generate_random_str(10))  # 输出示例：'xY3kL9pQ2s'
# random.seed()
# print()